<?php
require_once "TLSSigAPIv2.php";
//生成签名
function genSig($identifier, $sdkappid, $adminkey){
	$api = new \Tencent\TLSSigAPIv2($sdkappid, $adminkey);
    $sig = $api->genSig($identifier);//生成usersig
	return $sig ;
}
//效验签名
function verifySig($identifier, $sdkappid, $adminkey,$sig){
	$api = new \Tencent\TLSSigAPIv2($sdkappid, $adminkey);
	$init_time = 0;
	$expire = 0;
	$err_msg = '';
	$ret = $api->verifySig($sig, $identifier, $init_time, $expire, $err_msg);
	if (!$ret) {
		echo $err_msg . "\n";
	} else {
		echo "verify ok expire $expire init time $init_time\n";
	}
}
//效验签名
function verifySigWithUserBuf($identifier, $sdkappid, $adminkey,$sig){
	$api = new \Tencent\TLSSigAPIv2($sdkappid, $adminkey);
	$init_time = 0;
	$expire = 0;
	$err_msg = '';
	$userbuf = '';
	$ret = $api->verifySigWithUserBuf($sig, $identifier, $init_time, $expire,$userbuf, $err_msg);
	if (!$ret) {
		echo $err_msg . "\n";
	} else {
		echo "verify ok expire $expire init time $init_time userbuf $userbuf\n";
	}
}
//效验签名
function genSigWithUserBuf($identifier, $sdkappid, $adminkey){
	$api = new \Tencent\TLSSigAPIv2($sdkappid, $adminkey);
	$init_time = 0;
	$expire = 0;
	$err_msg = '';
	$userbuf = '';
	$sig = $api->genSigWithUserBuf($identifier, 86400*180, 'abc');
	echo $sig . "\n";
}

